using System;
using System.Windows.Forms;
using RollManager.Forms.MainPanels;
using RollManager.Library;

namespace RollManager.Forms.MenuDialogs
{
    public partial class AddActionDialog : MenuDialog
    {
        private int m_devLevelId;

        public AddActionDialog( AdminActionsPanel panel, int devLevelId ) : base(panel)
        {
            m_devLevelId = devLevelId;
            InitializeComponent();

            permissionsList.DataSource = Enum.GetValues( typeof( Permission ) );
        }

        private void okButton_Click( object sender, EventArgs e )
        {
            RollManager.Library.Action action = Database.AddAction( nameBox.Text, m_devLevelId, (Permission) permissionsList.SelectedValue );
            CloseAndAdd( action.Name, action );
        }

        private void cancelButton_Click( object sender, EventArgs e )
        {
            Close();
        }
    }
}